﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;

using QLTTAN.DTO;
namespace QLTTAN.DAL
{
    public class ChuongTrinhHocDAL
    {
        ConnectionData conn;

        public DataTable ChuongTrinhHoc_Load()
        {
            conn = new ConnectionData();
            return conn.GetData("CHUONGTRINHHOC_LOAD");
        }

        public int ChuongTrinhHoc_Insert(ChuongTrinhHocDTO CTH_DTO)
        {
            conn = new ConnectionData();

            int Nparameter = 4;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];

            name[0] = "TenChuongTrinh";
            value[0] = CTH_DTO.TenChuongTrinh;
            name[1] = "MaLoaiCT";
            value[1] = CTH_DTO.MaLoaiCT;
            name[2] = "MaTrinhDo";
            value[2] = CTH_DTO.MaTrinhDo;
            name[3] = "HocPhi";
            value[3] = CTH_DTO.HocPhi;

            return conn.UpdateData("CHUONGTRINHHOC_INSERT", name, value, Nparameter);
        }

        public int ChuongTrinhHoc_Update(ChuongTrinhHocDTO CTH_DTO)
        {
            conn = new ConnectionData();

            int Nparameter = 5;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];

            name[0] = "MaChuongTrinh";
            value[0] = CTH_DTO.MaChuongTrinh;
            name[1] = "TenChuongTrinh";
            value[1] = CTH_DTO.TenChuongTrinh;
            name[2] = "MaLoaiCT";
            value[2] = CTH_DTO.MaLoaiCT;
            name[3] = "MaTrinhDo";
            value[3] = CTH_DTO.MaTrinhDo;
            name[4] = "HocPhi";
            value[4] = CTH_DTO.HocPhi;

            return conn.UpdateData("CHUONGTRINHHOC_UPDATE", name, value, Nparameter);
        }

        public int ChuongTrinhHoc_Delete(ChuongTrinhHocDTO CTH_DTO)
        {
            conn = new ConnectionData();

            int Nparameter = 1;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];

            name[0] = "MaChuongTrinh";
            value[0] = CTH_DTO.MaChuongTrinh;

            return conn.UpdateData("CHUONGTRINHHOC_DELETE", name, value, Nparameter);
        }
    }
}
